package com.maweirdos.springSecurity.controller;

import com.maweirdos.springSecurity.domain.ResponseResult;
import com.maweirdos.springSecurity.domain.User;
import com.maweirdos.springSecurity.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Author:  Maweirdos
 * Date:  2024/6/22 下午3:48
 * Description:  登录控制器
 */
@RestController
public class LoginController {
    @Autowired
    //LoginService是我们在service目录写好的接口
    private LoginService loginService;

    @PostMapping("/user/login")
    //ResponseResult和user是我们在domain目录写好的类
    public ResponseResult login(@RequestBody User user){
        //登录
        return loginService.login(user);
    }

    @RequestMapping("user/logout")
    public ResponseResult logout(){
        return loginService.logout();
    }
}
